package com.cnpc.fyupdate.db.test;

import android.content.ContentValues;
import android.database.Cursor;
import android.text.TextUtils;


import com.cnpc.fyupdate.db.bean.BaseBean;
import com.cnpc.fyupdate.db.db.Table;
import com.cnpc.fyupdate.db.db.TableColumn;

import org.json.JSONObject;

/**
 * Created by songzhiiyn on 2017/1/22.
 */
@Table(name = "SmartDownloadBean")
public class SmartDownloadBean extends BaseBean<SmartDownloadBean> {

    @TableColumn(type = TableColumn.Types.TEXT, isIndex = true, isNotNull = true)
    public String downpath;

    @TableColumn(type = TableColumn.Types.INTEGER)
    public int threadid;

    @TableColumn(type = TableColumn.Types.INTEGER)
    public int downlength;

    @Override
    public SmartDownloadBean parseJSON(JSONObject jsonObj) {
        return null;
    }

    @Override
    public JSONObject toJSON() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public SmartDownloadBean cursorToBean(Cursor cursor) {
        this.downpath = cursor.getString(cursor.getColumnIndex("downpath"));
        this.threadid = cursor.getInt(cursor.getColumnIndex("threadid"));
        this.downlength = cursor.getInt(cursor.getColumnIndex("downlength"));
        return this;
    }

    @Override
    public ContentValues beanToValues() {
        ContentValues values = new ContentValues();
        if (!TextUtils.isEmpty(downpath)) {
            values.put("downpath", downpath);
        }
        if (!TextUtils.isEmpty(threadid+"")) {
            values.put("threadid", threadid);
        }
        if (!TextUtils.isEmpty(downlength+"")) {
            values.put("downlength", downlength);
        }
        return values;
    }

}
